﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Data;
using FlashCards.Dto;
using System.Runtime.Serialization;

namespace FlashCards.Service
{
    [ServiceContract(Namespace = "")]
    //[SilverlightFaultBehavior]
    public interface ISilverlightService
    {
        [OperationContract]
        string GetCategories();

        [OperationContract]
        string GetFlashcardPartTypes();

        [OperationContract]
        string GetFlashcardSet(int setId);

        [OperationContract]
        string GetUserData(int userId);

        //[OperationContract]
        //[FaultContract(typeof(CustomFault))]
        //void AddNewFlashcardSet(string serializedSet);

        [OperationContract]
        [FaultContract(typeof(CustomFault))]
        string AddNewFlashcardSet(string serializedSet, int? groupId);

        [OperationContract]
        [FaultContract(typeof(CustomFault))]
        void UpdateExistingSet(string serializedSet);

        [OperationContract]
        [FaultContract(typeof(CustomFault))]
        void SaveRepeat(string serializedRepeat);

        [OperationContract]
        [FaultContract(typeof(CustomFault))]
        string GetUserLastRepeat(int userId, int flashcardSetId);

        [OperationContract]
        string GetNetworkLastResult(int userId, int flashcardSetId);

    }

    [DataContract]
    public class CustomFault
    {
        public CustomFault(string message)
        {
            CustomFaultString = message;
        }

        [DataMember]
        public string CustomFaultString { get; set; }
    }
}
